<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>jQuery属性的获取和设置</title>
    <style>
        .class1 {
            width: 300px;
            height: 500px;
            background-color: blue;
            border: 1px solid black;
        }
    </style>
    <script type="text/javascript" src="https://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#btn1').click(function () {
                console.log($('div:first').attr('id'));
            });
            $('#btn2').click(function () {
                $('div').attr('class', 'class1');
                //input的 type属性无法被直接改变
                // $('input').attr('type','date');
                $('input').attr('id','input1');
                $('input').attr('name','username');
                //prop方法 专门用于 checked、readOnly、selected、disabled 的取值赋值
                // $('input').prop('readonly','readonly');
                $('input').prop('disabled','disabled');
            });
        });
    </script>
</head>
<body>
<div id="div1"></div>
<div></div>
<div></div>
<div></div>
<input type="text"/>
<button id="btn1">取值按钮1</button>
<button id="btn2">赋值按钮2</button>
</body>
</html>